// package-signin/pages/edit-rule/index.js
const app = getApp();
import { navBack } from '../../../common/env';

Page({
    data: {
        signinInfo: {},
        ruleInfo: '',
    },
    onLoad(options) {
        app.event.addListener('sendSigninInfo', this._handleSendSignin.bind(this));
    },
    onUnload() {
        app.event.removeListener('sendSigninInfo');
    },
    _handleSendSignin(signinInfo) {
        const { intro } = signinInfo;
        this.setData({
            signinInfo,
            ruleInfo: intro[0].resource,
        });
    },
    handleChange(e) {
        const { value } = e.detail;
        this.setData({
            ruleInfo: value,
        });
    },
    handleSave() {
        const { signinInfo, ruleInfo } = this.data;
        signinInfo.intro[0].resource = ruleInfo;
        app.event.trigger('getSigninInfo', signinInfo);
        navBack();
    },
})
